//
//  Color.swift
//  SwiftuiZsa
//
//  Created by hccc on 2023/7/20.
//

import Foundation
import SwiftUI

extension Color {
    /// 主文本色, #333333
    static var backgroundColor: Color = .hex(0x2B8C8C)
    
    /// 主文本色, #333333
    static var title: Color = .hex(0x333333)
    
    /// 子标题, 0x6D6E73
    static var subTitle: Color = .hex(0x6D6E73)
    
    /// #666666
    static var text: Color = .hex(0x666666)
    
    /// 子文本, #999999
    static var subText: Color = .hex(0x999999)
    
    /// 占位符颜色 #DDDDDD
    static var placeholder: Color = .hex(0xF9F9F9)
    
    /// 渐变色淡 0xFFC12E
    static var customOrangeShallow: Color = .hex(0xFFC12E)
    
    /// 主色 0xFE741D
    static var customOrange: Color = .hex(0xFE741D)
}

extension Color {
    static func hex(_ hex: UInt, _ alpha: CGFloat = 1.0) -> Color {
        let limit: CGFloat = 255
        let r: CGFloat = CGFloat((hex & 0xFF0000) >> 16) / limit
        let g: CGFloat = CGFloat((hex & 0x00FF00) >> 8) / limit
        let b: CGFloat = CGFloat((hex & 0x0000FF)) / limit
        return Color.init(.sRGB, red: r, green: g, blue: b, opacity: alpha)
    }
}
